using System;
using System.Configuration;
using System.Runtime.Remoting;
using IIS.Remoting.Shared;
using ODX.Core;

namespace IIS.Remoting.Client
{
    class Program
    {
        static void Main()
        {
            // Create a proxy object for a DataServer exposed by our server
            IDataProvider dataProvider = (IDataProvider)Activator.GetObject(
                typeof(IDataProvider),
                "http://localhost/odx/DataServer.soap");


            // Create a session and build entity proxies and schema DataSet
            Session session = new Session(dataProvider);
            session.RegisterAssembly(typeof(Person).Assembly);
            session.Prepare();

            // Create objects
            Person p = session.Create<Person>();
            p.Name = "Some Person";

            // And, finally, send them to the server
            session.Save();

            //string fn = ConfigurationManager.OpenExeConfiguration(
            //    ConfigurationUserLevel.None).FilePath;
            //RemotingConfiguration.Configure(fn, false);

            //IPersonService personService = (IPersonService)Activator.GetObject(
            //    typeof (IDataProvider),
            //    "http://localhost/odx/PersonService.soap");

            //// Create a disconnected session and
            //// build entity proxies and schema DataSet
            //Session session = new Session();
            //session.RegisterAssembly(typeof(Person).Assembly);
            //session.Prepare();

            //// register session to let ODX create returned entities on it
            //RemotingSessionManager.RegisterChannelSession(session);

            //Person p = session.Create<Person>();
            //p.Name = "Some Person";

            //// Cal PersonSerice to obtain a signature
            //personService.SignPerson(ref p);
            //Console.WriteLine("Person signature: {0} ", p.Signature);

            //personService.Save(p);
        }
    }
}